kind: ClusterConfiguration
apiVersions:
- apiVersion: deckhouse.io/v1
  openAPISpec:
    type: object
    description: |
      General parameters of a cluster.

      Defines, for example, network and CRI parameters, control plane version, etc. Some parameters can be changed after the cluster is bootstrapped, during its operation.

      To change the `ClusterConfiguration` resource in a running cluster, run the following command:

      ```shell
      kubectl -n d8-system exec -ti deploy/deckhouse -- deckhouse-controller edit cluster-configuration
      ```
    additionalProperties: false
    required: [apiVersion, kind, clusterType, kubernetesVersion, podSubnetCIDR, serviceSubnetCIDR, clusterDomain]
    x-examples:
    - apiVersion: deckhouse.io/v1
      kind: ClusterConfiguration
      podSubnetNodeCIDRPrefix: "24"
      podSubnetCIDR: 10.244.0.0/16
      serviceSubnetCIDR: 192.168.0.0/16
      kubernetesVersion: "1.25"
      clusterDomain: k8s.internal
      clusterType: "Cloud"
      cloud:
        prefix: k8s-dev
        provider: Yandex
      proxy:
        httpProxy: https://user:password@proxy.company.my:8443
        httpsProxy: https://user:password@proxy.company.my:8443
        noProxy:
        - company.my
    properties:
      apiVersion:
        type: string
        description: Version of the Deckhouse API.
        enum: [deckhouse.io/v1, deckhouse.io/v1alpha1]
      kind:
        type: string
        enum: [ClusterConfiguration]
      clusterType:
        type: string
        x-unsafe: true
        description: |
          Type of the cluster infrastructure:
          - `Static` — a cluster on bare metal (physical servers) or virtual machines. In the case of virtual machines, it is assumed that Deckhouse doesn't have access to the API for managing virtual machines (they are managed by the administrator using the usual cloud infrastructure tools);
          - `Cloud` — a cluster deployed on the resources of a cloud infrastructure. This type implies that Deckhouse has access to the cloud infrastructure API for managing virtual machines.
        enum: [Cloud, Static]
      cloud:
        type: object
        x-unsafe: true
        description: |
          Cloud provider-related settings (if the `Cloud` [clusterType](#clusterconfiguration-clustertype) is used).
        required: [provider]
        additionalProperties: false
        properties:
          provider:
            type: string
            description: |
              Cloud provider.
            enum:
            - "OpenStack"
            - "AWS"
            - "GCP"
            - "Yandex"
            - "vSphere"
            - "Azure"
            - "VCD"
            - "Zvirt"
          prefix:
            type: string
            description: |
              A prefix of the objects to be created in the cloud.

              Is used, for example, to distinguish objects created for different clusters, to configure routing, etc.
            pattern: '^[a-z0-9]([-a-z0-9]*[a-z0-9])?$'
      podSubnetCIDR:
        type: string
        x-unsafe: true
        description: |
          Address space of the cluster's Pods.

          > Caution! Normally, you won't be able to change the parameter in a running cluster. To avoid this limitation use specific flag.
      podSubnetNodeCIDRPrefix:
        type: string
        description: |
          The prefix of Pod network on a node.

          > Caution! Normally, you won't be able to change the parameter in a running cluster. To avoid this limitation use specific flag.
        default: "24"
      serviceSubnetCIDR:
        type: string
        x-unsafe: true
        description: |
          Address space of the cluster's services.

          > Caution! Normally, you won't be able to change the parameter in a running cluster. To avoid this limitation use specific flag.
      clusterDomain:
        type: string
        description: |
          Cluster domain (used for local routing).

          **Please note:** the domain must not match the domain used in the DNS name template in the [publicDomainTemplate](../deckhouse-configure-global.html#parameters-modules-publicdomaintemplate) parameter. For example, you cannot set `cluster Domain: cluster.local` and `publicDomainTemplate: %s.cluster.local` at the same time.
        default: "cluster.local"
      defaultCRI:
        type: string
        description: |
          The container runtime type that used on cluster nodes (NodeGroups) by default.

          If the value `NotManaged` is used, then Deckhouse does not manage the container runtime (and doesn't install it).
          In this case, it is necessary to use images for NodeGroups on which the container runtime is already installed.
        enum:
        - "Docker"
        - "Containerd"
        - "NotManaged"
        default: "Containerd"
      kubernetesVersion:
        type: string
        description: |
          Kubernetes control plane version to use in a cluster.

          Changing a parameter in a running cluster will [automatically update](https://deckhouse.io/documentation/v1/modules/040-control-plane-manager/#version-control) the cluster's control plane version.

          If `Automatic` is specified, then the control plane version is used, which is considered stable at the moment. If the stable version of control plane is less than the maximum version that has ever been installed in the cluster, more than 1 minor version, then the version of the cluster will not be changed.
          The version may change when the minor version of the Deckhouse release is changed (see a corresponding release message).
        enum:
        - "1.25"
        - "1.26"
        - "1.27"
        - "1.28"
        - "1.29"
        - "Automatic"
      proxy:
        x-doc-d8Revision: ee
        type: object
        description: |
          Global proxy setup (mainly for working in air-gapped environments).

          The parameters described in this section will be translated into the environment variables `HTTP_PROXY`, `HTTPS_PROXY`, and `NO_PROXY` for all cluster nodes and Deckhouse components. This will result in HTTP(S) requests (curl, git, registry, etc.) to all resources not listed in the `noProxy` parameter being made through a proxy. Note that the `podSubnetCIDR` and `serviceSubnetCIDR` subnets, as well as the `clusterDomain` domain are added to `noProxy` automatically.

          > **Caution!** To avoid interfering with internal requests, make sure you list all the host subnets in the `noProxy` parameter.
        additionalProperties: false
        properties:
          httpProxy:
            type: string
            x-doc-d8Revision: ee
            pattern: ^https?://([0-9a-zA-Z\.\-\_]+(\:[!*'();:@&=+$,/?%#\[\]0-9a-zA-Z\.\-\_]+)?@)?[0-9a-zA-Z\.\-]+(\:[0-9]{1,5})?$
            description: |
              Proxy URL for HTTP requests.

              If necessary, specify the proxy server's username, password, and port.
            x-examples:
            - 'http://proxy.company.my'
            - 'https://user:password@proxy.company.my:8443'
          httpsProxy:
            type: string
            x-doc-d8Revision: ee
            pattern: ^https?://([0-9a-zA-Z\.\-\_]+(\:[!*'();:@&=+$,/?%#\[\]0-9a-zA-Z\.\-\_]+)?@)?[0-9a-zA-Z\.\-]+(\:[0-9]{1,5})?$
            description: |
              Proxy URL for HTTPS requests.

              If necessary, specify the proxy server's username, password, and port.
            x-examples:
            - 'http://proxy.company.my'
            - 'https://user:password@proxy.company.my:8443'
          noProxy:
            x-doc-d8Revision: ee
            description: |
              List of no proxy IP and domain entries.

              For wildcard domains, use a domain name with a dot prefix, e.g., ".example.com".
            type: array
            items:
              type: string
              pattern: '^[a-z0-9\-\./]+$'
    oneOf:
    - properties:
        clusterType:
           enum: [Static]
    - properties:
        clusterType:
           enum: [Cloud]
      cloud: {}
      required: [cloud]
